﻿<?php
require('configs/include.php');

class a_cargar_modulos extends super_controller {

    public function cargar_modulos() {
        $cod['modulo']['kernel'] = $this->post->id;
        $options['modulo']['lvl2'] = "by_kernel";
        $this->orm->connect();
        $this->orm->read_data(array("modulo"), $options, $cod);
        $modulos = $this->orm->get_objects("modulo");
        $this->orm->close();
        if (sizeof($modulos) == 0) {
            echo "alert";
        } else {
            $array_modulos = array();
            for ($i = 0; $i < sizeof($modulos); $i++) {
                $array_modulos[$i] = $modulos[$i]->get('id') . "-" . $modulos[$i]->get('nombre');
            }
            $datos_modulos = implode("//", $array_modulos);
            echo $datos_modulos;
        }
    }

    public function run() {
        try {
            $this->cargar_modulos();
        } catch (Exception $e) {
            $this->error = 1;
            $this->msg_warning = $e->getMessage();
            $this->img_warning = "incorrect.png";
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->engine->assign('img_warning', $this->img_warning);
            $this->temp_aux = 'message.tpl';
        }
    }

}

$call = new a_cargar_modulos();
$call->run();
?>